package com.example.chat.model;

import com.example.chat.type.EmployeeAccountStatus;
import com.example.chat.type.EmployeeType;
import com.example.chat.type.SexType;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

@Entity
@Table(name = "VDOA001_EMPLOYEE")
@Data
@DynamicInsert
@DynamicUpdate
@NoArgsConstructor
@ToString
public class Employee extends BaseEntity implements Serializable {

    private static final long serialVersionUID = 3449814372865150506L;
    @Id
    @Column(name = "DOA001_ID", length = 50)
    @GenericGenerator(name = "uuid", strategy = "org.hibernate.id.UUIDGenerator")
    @GeneratedValue(generator = "uuid")
    private String id;

    /**
     * 职员姓名
     */
    @Column(name = "DOA001_NAME", length = 50)
    private String name;

    /**
     * 性别（MAN | WOMAN）
     */
    @Column(name = "DOA001_SEX")
    @Enumerated(EnumType.STRING)
    private SexType sex;

    /**
     * 电话号码
     */
    @Column(name = "DOA001_PHONE_NUMBER", length = 50)
    private String phoneNumber;

    /**
     * 出生日期
     */
    @Column(name = "DOA001_BIRTH_DATE")
    @Temporal(TemporalType.DATE)
    private Date birthDate;

    /**
     * 邮箱
     */
    @Column(name = "DOA001_MAIL", length = 50)
    private String email;

    /**
     * 密码
     */
    @Column(name = "DOA001_PASSWORD", length = 32)
    private String password;

    @Column(name = "DOA001_DOCUMENT_NUMBER")
    private String documentNumber;

    /**
     * 是否已重置密码（第一次登录需重置）
     */
    @Column(name = "DOA001_PASSWORD_RESET")
    private Boolean passwordReset = Boolean.FALSE;

    /**
     * 身份证号
     */
    @Column(name = "DOA001_CARD_CODE", length = 50)
    private String idCardCode;

    /**
     * 等级（5-15）
     */
    @Column(name = "DOA001_LEVEL", length = 2)
    private String level;

//    /**
//     * 户籍类型（农业、城镇）
//     */
//    @Column(name = "DOA001_HOUSEHOLD_TYPE")
//    @Enumerated(value = EnumType.STRING)
//    private HouseholdType householdType;

    /**
     * 建行开户银行
     */
    @Column(name = "DOA001_BANK_ACCOUNT_SITE", length = 50)
    private String bankAccountSite;

    /**
     * 建行卡号
     */
    @Column(name = "DOA001_BANK_ACCOUNT_CODE", length = 50)
    private String bankAccountCode;

    /**
     * 员工类型
     */
    @Column(name = "DOA001_EMPLOYEE_TYPE", length = 10)
    @Enumerated(value = EnumType.STRING)
    private EmployeeType employeeType;

    /**
     * 入职日期
     */
    @Column(name = "DOA001_ENTRY_DATE")
    @Temporal(TemporalType.DATE)
    private Date entryDate;

    /**
     * 实习转正式日期（实习生转正才存日期）
     */
    @Column(name = "DOA001_FORMAL_DATE")
    @Temporal(TemporalType.DATE)
    private Date formalDate;

    /**
     * 首次社保缴纳时间
     */
    @Column(name = "DOA001_FIRST_SOC_S")
    @Temporal(TemporalType.TIMESTAMP)
    private Date firstSocialDate;

    /**
     * 合同开始日期
     */
    @Column(name = "DOA001_PACT_START_DATE")
    @Temporal(TemporalType.DATE)
    private Date pactStartDate;

    /**
     * 合同结束日期
     */
    @Column(name = "DOA001_PACT_END_DATE")
    @Temporal(TemporalType.DATE)
    private Date pactEndDate;

    /**
     * 职位id
     */
    @Column(name = "DOA001_POSITION_ID", length = 50)
    private String positionId;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "DOA001_POSITION_ID", updatable = false, insertable = false, foreignKey = @ForeignKey(name = "none"))
    private Position position;

    /**
     * 部门id
     */
    @Column(name = "DOA001_DEPT_ID", length = 50)
    private String deptId;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "DOA001_DEPT_ID", updatable = false, insertable = false, foreignKey = @ForeignKey(name = "none"))
    private Dept dept;

    /**
     * 主管id
     */
    @Column(name = "DOA001_SUPERVISOR_ID", length = 50)
    private String supervisorId;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "DOA001_SUPERVISOR_ID", updatable = false, insertable = false, foreignKey = @ForeignKey(name = "none"))
    private Employee supervisor;

    /**
     * 所属区域
     */
    @Column(name = "DOA001_REGION_ID", length = 50)
    private String regionId;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "DOA001_REGION_ID", updatable = false, insertable = false, foreignKey = @ForeignKey(name = "none"))
    private Region region;

    /**
     * 公司id
     */
    @Column(name = "DOA001_COMPANY_ID", length = 50)
    private String companyId;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "DOA001_COMPANY_ID", updatable = false, insertable = false, foreignKey = @ForeignKey(name = "none"))
    private Company company;

    /**
     * 是否有效
     */
    @Column(name = "DOA001_ACTIVE")
    private Boolean active = true;

    /**
     * 是否已删除
     */
    @Column(name = "DOA001_DELETED")
    private Boolean deleted = false;

    /**
     * 账号状态
     */
    @Column(name = "DOA001_ACCOUNT_STATUS")
    @Enumerated(value = EnumType.STRING)
    private EmployeeAccountStatus accountStatus = EmployeeAccountStatus.INCUMBENCY;

    /**
     * 试用期结束提醒日期
     */
    @Column(name = "DOA001_TRIAL_END_REMIND_DATE")
    @Temporal(TemporalType.DATE)
    private Date trialEndRemindDate;
}